<template>
  <!--委外诉讼案件-->
  <section class="page company-manage">
    <data-form :model="queryModel" :page="pageService" @handleResetForm="follFeedback" @onSearch="refreshData">
      <template slot="inputs">
        <el-form-item label="订单编号" prop="caseNumber">
          <el-input v-model="queryModel.caseNumber"></el-input>
        </el-form-item>
        <el-form-item label="客户姓名" prop="personalName">
          <el-input v-model="queryModel.personalName"></el-input>
        </el-form-item>
        <el-form-item label="手机号" prop="mobileNo">
          <el-input v-model="queryModel.mobileNo"></el-input>
        </el-form-item>
        <el-form-item label="身份证号" prop="idCard">
          <el-input v-model="queryModel.idCard"></el-input>
        </el-form-item>
        <el-form-item label="欠款金额" prop="outAmount">
          <number-range v-model="queryModel.outAmount"></number-range>
        </el-form-item>
        <el-form-item label="逾期期数" prop="overduePeriod">
          <el-select clearable placeholder="请选择" v-model="queryModel.overduePeriod">
            <el-option :key="index" :label="name" :value="code.replace(/M|\+/, '')" v-for="{index,name,code} in $dict.getDictData('OverduePeriodStatus')"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="逾期天数" prop="overdueDays">
          <number-range v-model="queryModel.overdueDays"></number-range>
        </el-form-item>
        <el-form-item label="产品类型" prop="productCategory">
          <el-input v-model="queryModel.productCategory"></el-input>
        </el-form-item>
        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="queryModel.productName"></el-input>
        </el-form-item>
      </template>
    </data-form>
    <data-box :data="dataList" :page="pageService" :selectionList.sync="selectionList" @onPageChange="refreshData">
      <template slot="buttons">
        <el-button @click="moveToStay">移入诉讼待分配</el-button>
      </template>
      <template slot="columns">
        <el-table-column :min-width="$helper.getColumnWidth(6)" label="操作">
          <template>
            <el-button type="text">查看诉讼跟进</el-button>
          </template>
        </el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="订单编号" prop="caseNumber">
          <template slot-scope="scope">
            <el-button @click="openExecutionPage(scope.row)" type="text">{{scope.row.caseNumber}}</el-button>
          </template>
        </el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="批次号" prop="batchNumber"></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(3)" label="律所" prop="deptName"></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(3)" label="客户名称" prop="personalName" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="手机号" prop="mobileNo" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="身份证号" prop="idCard" show-overflow-tooltip></el-table-column>
        <el-table-column :formatter="(row) => $filter.dictConvert(row.addressType,'AddressType')" :min-width="$helper.getColumnWidth(4)" label="地址类型" prop="addressType" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="欠款金额" prop="overdueAmount" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="逾期期数" prop="overduePeriod" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="逾期天数" prop="overdueDays" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="产品类型" prop="productCategory" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="产品名称" prop="productName" show-overflow-tooltip></el-table-column>
        <!-- <el-table-column prop="customerCategory" label="顾客类型" :min-width="$helper.getColumnWidth(4)" show-overflow-tooltip>
        </el-table-column>-->
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="电催催收员" prop="currentCollectorName" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(6)" label="案件创建时间" prop="createTime">
          <template slot-scope="scope">
            <span>{{scope.row.createTime | dateTimeFormat}}</span>
          </template>
        </el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="诉讼状态" prop="collectionStatus" show-overflow-tooltip></el-table-column>
      </template>
    </data-box>
  </section>
</template>

<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { Auth, Layout, Dependencies } from "~/core/decorator";
import { CompanyService } from "~/services/management-service/company.service";
import { PageService } from "~/utils/page.service";
import { SortService } from "~/utils/sort.service";
import DataForm from "~/components/common/data-form.vue";
import DataBox from "~/components/common/data-box.vue";
import NumberRange from "~/components/common/number-range.vue";
import { OutsourceLawsuitBackService } from "~/services/domain-service/outsource-lawsuit-back-manage.service";
import { OutsourceLawsuitService } from "~/services/domain-service/outsource-lawsuit-manage-index.service";
import {
  ApplyType,
  CASE_CHANNEL,
  CASE_HALT_CATEGORY,
  MENU_CHANNEL
} from "~/config/enum.config";
import { Mutation, Getter, namespace, State } from "vuex-class";
const CollectionExecutionModule = namespace("collection-execution");

// @Auth(1012)
@Layout("workspace")
@Component({
  components: {
    NumberRange
  }
})
export default class OutsourceLawsuitBackManageIndex extends Vue {
  @Dependencies(OutsourceLawsuitBackService)
  private outsourceLawsuitBackService: OutsourceLawsuitBackService;
  @Dependencies(PageService)
  private pageService: PageService;
  @Dependencies(SortService)
  private sortService: SortService;
  @Dependencies(OutsourceLawsuitService)
  private outsourceLawsuitService: OutsourceLawsuitService;
  @CollectionExecutionModule.Action private openCollectionExecution;

  private isCheck: any = false;
  private dataList: any[] = [];
  private selectionList: any[] = [];
  private caseIds: any[] = [];
  private lawsuitId: any = {};
  private dialog: any = {
    setCaseDetail: false
  };
  // form 查询表单参数
  private queryModel: any = {
    batchNumber: "",
    caseNumber: "",
    personalName: "",
    mobileNo: "",
    idCard: "",
    localAddress: "",
    currentCollector: "",
    overduePeriod: "",
    turnSource: "",
    productCategory: "",
    productName: "",
    followInTime: "",
    outAmount: {
      max: "",
      min: ""
    },
    overdueDays: {
      max: "",
      min: ""
    }
  };
  private active: number = 0;
  private lawsuitObj: any = {};
  private stepDate: any = [
    { step: "LAWSUIT_TPYE", active: -1 }, //添加诉讼类型
    { step: "COURT", active: 0 }, //立案
    { step: "CHECK", active: 1 }, // 庭审
    { step: "COURT_EXECUTE", active: 2 }, // 执行立案
    { step: "EXECUTION", active: 3 }, // 案件执行中
    { step: "END", active: 4 }, // 执行终结
    { step: "TAKE", active: 5 } // 参与分配
  ];
  private followType: any = {};
  private stepType: any = {
    lawsuitFollowType: "",
    lawsuitObj: this.lawsuitObj
  };

  private mounted() {
    this.refreshData();
  }
  /**
   * 查询列表
   */
  private refreshData() {
    this.outsourceLawsuitBackService
      .searchLawsuitRecoveryList(
        this.queryModel,
        this.pageService,
        this.sortService
      )
      .subscribe(data => {
        this.dataList = data;
      });
  }
  private moveToStay() {
    if (this.selectionList.length === 0) {
      this.$message.info("请选择要回收的案件");
      return;
    }
    this.caseIds = [];
    this.selectionList.map(v => {
      this.caseIds.push(v.id);
    });
    this.outsourceLawsuitBackService
      .moveLawsuitWait({ caseIds: this.caseIds })
      .subscribe(data => {
        this.$message.success("案件分配成功");
        this.refreshData();
      });
  }
  private checkFllow() { }

  private litigationFollow(row) {
    this.lawsuitObj = row;
    // this.dialog.litigationFollow = true;
    this.getStep(); //查询步骤
  }
  /**
   * 获取步骤
   */
  private getStep() {
    this.outsourceLawsuitService
      .getCourtInfoStep({ id: this.lawsuitObj.id })
      .subscribe(data => {
        this.active = -1;
        this.stepDate.map(v => {
          if (v.step === data) {
            this.active = v.active;
          }
        });
        if (this.active !== -1) {
          this.getFllowInfo();
          this.dialog.setCaseDetail = true;
          this.isCheck = true;
        }
      });
  }
  private getFllowInfo() {
    // this.outsourceLawsuitService.getFollowInfo({id:this.lawsuitObj.id}).subscribe(
    //   data => {
    //     if(data){
    //       // this.dialog.setUpForce = true
    //       this.followType = this.lawsuitObj;
    //       this.followType.lawsuitFollowType = data.lawsuitFollowType
    //     }
    //   },
    //   ({ msg }) => {
    //   }
    // );
  }
  /**
   * 进入查看执行页
   */
  private openExecutionPage(row) { }
  /**
   * 重置numberRange
   */
  private follFeedback() {
    this.queryModel.overdueAmount = { max: "", min: "" };
    this.queryModel.overdueDays = { max: "", min: "" };
  }
}
</script>

<style lang="less">
</style>


